package cn.diancan.member.security;

import org.apache.struts2.ServletActionContext;

/** 
 * @author Sky<br>
 * 后台 登录 取值 退出
 */
public class MemberAuthUtil {
	
	public static String SESSIONKEYNAME="login_menber_Id";
	public static String SESSIONUSERNAME="login_user_name";
	public static String SESSIONUSERIMAGE="login_user_image";
	/**
	 * 登录
	 * @param value
	 * @throws Exception
	 */
	public static void setValue(Long value) throws Exception{
		ServletActionContext.getRequest().getSession().setAttribute(SESSIONKEYNAME,value);
	}
	//设置用户名
	public static void setUserName(String value) throws Exception{
		ServletActionContext.getRequest().getSession().setAttribute(SESSIONUSERNAME,value);
	}
	//设置头像地址
	public static void setUserImage(String value) throws Exception{
		ServletActionContext.getRequest().getSession().setAttribute(SESSIONUSERIMAGE,value);
	}
	/**
	 * 取值
	 * @return
	 * @throws Exception
	 */
	public static Long getValue() throws Exception{ 
		return Long.valueOf(ServletActionContext.getRequest().getSession().getAttribute(SESSIONKEYNAME).toString());
	}
	/**
	 * 退出
	 * @throws Exception
	 */
	public static void loginOut() throws Exception{
		ServletActionContext.getRequest().getSession().removeAttribute(SESSIONKEYNAME);
		ServletActionContext.getRequest().getSession().removeAttribute(SESSIONUSERNAME);
		ServletActionContext.getRequest().getSession().removeAttribute(SESSIONUSERIMAGE);
	}
}
